home *** CD-ROM | disk | FTP | other *** search
/ Digital Background Bonanza / Digital Background Bonanza - Disc 1.iso / pc / DBB1.swf / scripts / __Packages / mx / controls / TextInput.as < prev    next >
Encoding:
Text File  |  2007-03-09  |  7.2 KB  |  310 lines

  1. class mx.controls.TextInput extends mx.core.UIComponent
  2. {
  3.    var owner;
  4.    var enterListener;
  5.    var label;
  6.    var focusTextField;
  7.    var _color;
  8.    var border_mc;
  9.    var tfx;
  10.    var tfy;
  11.    var tfw;
  12.    var tfh;
  13.    var bind;
  14.    var updateModel;
  15.    static var symbolName = "TextInput";
  16.    static var symbolOwner = mx.controls.TextInput;
  17.    static var version = "2.0.2.126";
  18.    var className = "TextInput";
  19.    var initializing = true;
  20.    var clipParameters = {text:1,editable:1,password:1,maxChars:1,restrict:1};
  21.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.TextInput.prototype.clipParameters,mx.core.UIComponent.prototype.clipParameters);
  22.    var _maxWidth = mx.core.UIComponent.kStretch;
  23.    var __editable = true;
  24.    var initText = "";
  25.    function TextInput()
  26.    {
  27.       super();
  28.    }
  29.    function addEventListener(event, handler)
  30.    {
  31.       if(event == "enter")
  32.       {
  33.          this.addEnterEvents();
  34.       }
  35.       super.addEventListener(event,handler);
  36.    }
  37.    function enterOnKeyDown()
  38.    {
  39.       if(Key.getAscii() == 13)
  40.       {
  41.          this.owner.dispatchEvent({type:"enter"});
  42.       }
  43.    }
  44.    function addEnterEvents()
  45.    {
  46.       if(this.enterListener == undefined)
  47.       {
  48.          this.enterListener = new Object();
  49.          this.enterListener.owner = this;
  50.          this.enterListener.onKeyDown = this.enterOnKeyDown;
  51.       }
  52.    }
  53.    function init(Void)
  54.    {
  55.       super.init();
  56.       this.label.styleName = this;
  57.       this.tabChildren = true;
  58.       this.tabEnabled = false;
  59.       this.focusTextField = this.label;
  60.       this._color = mx.core.UIObject.textColorList;
  61.       this.label.onSetFocus = function()
  62.       {
  63.          this._parent.onSetFocus();
  64.       };
  65.       this.label.onKillFocus = function(n)
  66.       {
  67.          this._parent.onKillFocus(n);
  68.       };
  69.       this.label.drawFocus = function(b)
  70.       {
  71.          this._parent.drawFocus(b);
  72.       };
  73.       this.label.onChanged = this.onLabelChanged;
  74.    }
  75.    function setFocus()
  76.    {
  77.       Selection.setFocus(this.label);
  78.    }
  79.    function onLabelChanged(Void)
  80.    {
  81.       this._parent.dispatchEvent({type:"change"});
  82.       this._parent.dispatchValueChangedEvent(this.text);
  83.    }
  84.    function createChildren(Void)
  85.    {
  86.       super.createChildren();
  87.       if(this.border_mc == undefined)
  88.       {
  89.          this.createClassObject(_global.styles.rectBorderClass,"border_mc",0,{styleName:this});
  90.       }
  91.       this.border_mc.swapDepths(this.label);
  92.       this.label.autoSize = "none";
  93.    }
  94.    function get html()
  95.    {
  96.       return this.getHtml();
  97.    }
  98.    function set html(value)
  99.    {
  100.       this.setHtml(value);
  101.    }
  102.    function getHtml()
  103.    {
  104.       return this.label.html;
  105.    }
  106.    function setHtml(value)
  107.    {
  108.       if(value != this.label.html)
  109.       {
  110.          this.label.html = value;
  111.       }
  112.    }
  113.    function get text()
  114.    {
  115.       return this.getText();
  116.    }
  117.    function set text(t)
  118.    {
  119.       this.setText(t);
  120.    }
  121.    function getText()
  122.    {
  123.       if(this.initializing)
  124.       {
  125.          return this.initText;
  126.       }
  127.       if(this.label.html == true)
  128.       {
  129.          return this.label.htmlText;
  130.       }
  131.       return this.label.text;
  132.    }
  133.    function setText(t)
  134.    {
  135.       if(this.initializing)
  136.       {
  137.          this.initText = t;
  138.       }
  139.       else
  140.       {
  141.          var _loc2_ = this.label;
  142.          if(_loc2_.html == true)
  143.          {
  144.             _loc2_.htmlText = t;
  145.          }
  146.          else
  147.          {
  148.             _loc2_.text = t;
  149.          }
  150.       }
  151.       this.dispatchValueChangedEvent(t);
  152.    }
  153.    function size(Void)
  154.    {
  155.       this.border_mc.setSize(this.width,this.height);
  156.       var _loc2_ = this.border_mc.borderMetrics;
  157.       var _loc6_ = _loc2_.left + _loc2_.right;
  158.       var _loc3_ = _loc2_.top + _loc2_.bottom;
  159.       var _loc5_ = _loc2_.left;
  160.       var _loc4_ = _loc2_.top;
  161.       this.tfx = _loc5_;
  162.       this.tfy = _loc4_;
  163.       this.tfw = this.width - _loc6_;
  164.       this.tfh = this.height - _loc3_;
  165.       this.label.move(this.tfx,this.tfy);
  166.       this.label.setSize(this.tfw,this.tfh + 1);
  167.    }
  168.    function setEnabled(enable)
  169.    {
  170.       this.label.type = !(this.__editable == true || enable == false) ? "dynamic" : "input";
  171.       this.label.selectable = enable;
  172.       var _loc2_ = this.getStyle(!enable ? "disabledColor" : "color");
  173.       if(_loc2_ == undefined)
  174.       {
  175.          _loc2_ = !enable ? 8947848 : 0;
  176.       }
  177.       this.setColor(_loc2_);
  178.    }
  179.    function setColor(col)
  180.    {
  181.       this.label.textColor = col;
  182.    }
  183.    function onKillFocus(newFocus)
  184.    {
  185.       if(this.enterListener != undefined)
  186.       {
  187.          Key.removeListener(this.enterListener);
  188.       }
  189.       if(this.bind != undefined)
  190.       {
  191.          this.updateModel(this.text);
  192.       }
  193.       super.onKillFocus(newFocus);
  194.    }
  195.    function onSetFocus(oldFocus)
  196.    {
  197.       var f = Selection.getFocus();
  198.       var o = eval(f);
  199.       if(o != this.label)
  200.       {
  201.          Selection.setFocus(this.label);
  202.          return undefined;
  203.       }
  204.       if(this.enterListener != undefined)
  205.       {
  206.          Key.addListener(this.enterListener);
  207.       }
  208.       super.onSetFocus(oldFocus);
  209.    }
  210.    function draw(Void)
  211.    {
  212.       var _loc2_ = this.label;
  213.       var _loc4_ = this.getText();
  214.       if(this.initializing)
  215.       {
  216.          this.initializing = false;
  217.          delete this.initText;
  218.       }
  219.       var _loc3_ = this._getTextFormat();
  220.       _loc2_.embedFonts = _loc3_.embedFonts == true;
  221.       if(_loc3_ != undefined)
  222.       {
  223.          _loc2_.setTextFormat(_loc3_);
  224.          _loc2_.setNewTextFormat(_loc3_);
  225.       }
  226.       _loc2_.multiline = false;
  227.       _loc2_.wordWrap = false;
  228.       if(_loc2_.html == true)
  229.       {
  230.          _loc2_.setTextFormat(_loc3_);
  231.          _loc2_.htmlText = _loc4_;
  232.       }
  233.       else
  234.       {
  235.          _loc2_.text = _loc4_;
  236.       }
  237.       _loc2_.type = !(this.__editable == true || this.enabled == false) ? "dynamic" : "input";
  238.       this.size();
  239.    }
  240.    function setEditable(s)
  241.    {
  242.       this.__editable = s;
  243.       this.label.type = !s ? "dynamic" : "input";
  244.    }
  245.    function get maxChars()
  246.    {
  247.       return this.label.maxChars;
  248.    }
  249.    function set maxChars(w)
  250.    {
  251.       this.label.maxChars = w;
  252.    }
  253.    function get length()
  254.    {
  255.       return this.label.length;
  256.    }
  257.    function get restrict()
  258.    {
  259.       return this.label.restrict;
  260.    }
  261.    function set restrict(w)
  262.    {
  263.       this.label.restrict = w != "" ? w : null;
  264.    }
  265.    function get hPosition()
  266.    {
  267.       return this.label.hscroll;
  268.    }
  269.    function set hPosition(w)
  270.    {
  271.       this.label.hscroll = w;
  272.    }
  273.    function get maxHPosition()
  274.    {
  275.       return this.label.maxhscroll;
  276.    }
  277.    function get editable()
  278.    {
  279.       return this.__editable;
  280.    }
  281.    function set editable(w)
  282.    {
  283.       this.setEditable(w);
  284.    }
  285.    function get password()
  286.    {
  287.       return this.label.password;
  288.    }
  289.    function set password(w)
  290.    {
  291.       this.label.password = w;
  292.    }
  293.    function get tabIndex()
  294.    {
  295.       return this.label.tabIndex;
  296.    }
  297.    function set tabIndex(w)
  298.    {
  299.       this.label.tabIndex = w;
  300.    }
  301.    function set _accProps(val)
  302.    {
  303.       this.label._accProps = val;
  304.    }
  305.    function get _accProps()
  306.    {
  307.       return this.label._accProps;
  308.    }
  309. }
  310.